﻿using GDGeek;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace MrPP.SerriedCabinet
{
    public class BoxOperation : GDGeek.Singleton<BoxOperation>
    {

        public Task open(int id) {
            string uri = Restful.RestfulManager.Uri("open");
            var item = CabinetGroup.Instance.data.cabinets.item[id];
            var op = Restful.RestfulManager.Instance.options(uri, new System.Collections.Generic.Dictionary<string, string> { { "area", item.area.ToString() }, { "column", item.index.ToString() } });
            var task = Restful.RestfulManager.Instance.getTask<ResultData>(op, delegate (ResultData result)
            {
                Debug.Log(result.time);
            });

            return task;
        }

        public Task close()
        {
            var op = Restful.RestfulManager.Instance.options(Restful.RestfulManager.Uri("close"));
            var task = Restful.RestfulManager.Instance.getTask<ResultData>(op, delegate (ResultData result)
            {
                Debug.Log(result.time);
            });



            return task;
        }
        public Task close(int id) {

            string uri = Restful.RestfulManager.Uri("close");
            var item = CabinetGroup.Instance.data.cabinets.item[id];
            var op = Restful.RestfulManager.Instance.options(uri, new System.Collections.Generic.Dictionary<string, string> { { "area", item.area.ToString() }, { "column", item.index.ToString() } });

            var task = Restful.RestfulManager.Instance.getTask<ResultData>(op, delegate (ResultData result)
            {
                Debug.Log(result.time);
            });



            return task;
        }

        public Task stop() {

            var op = Restful.RestfulManager.Instance.options(Restful.RestfulManager.Uri("stop"));
            var task = Restful.RestfulManager.Instance.getTask<ResultData>(op, delegate (ResultData result)
            {
                Debug.Log(result.time);
            });
            return task;
        }

        public Task ventilate() {
            Debug.LogError("@@@@@");
           var op = Restful.RestfulManager.Instance.options(Restful.RestfulManager.Uri("ventilate"));
            var task = Restful.RestfulManager.Instance.getTask<ResultData>(op, delegate (ResultData result)
            {
                Debug.LogError(result.time);
            });
            return task;
        }
    }
}
